import { getJson } from "../../core/ajax";
class AtlasJsonLoader{
    static instance = null;
        
    constructor(){
        if (AtlasJsonLoader.instance) {
            return AtlasJsonLoader.instance
        }
        this.atlasJsonMap=new Map();
        this.atlasJsonRequestMap=new Map();
    }
    async load(url,opts={}){
        if(this.atlasJsonMap.has(url)){
            return this.atlasJsonMap.get(url);
        }else if (this.atlasJsonRequestMap.has(url)) {
            let info = await this.atlasJsonRequestMap.get(url);
            opts.info=info;
            return opts;
        }else{
            this.atlasJsonRequestMap.set(url, getJson(url+"atlas.json"));
            let info=await getJson(url+"atlas.json");
            opts.info=info;
            this.atlasJsonMap.set(url,opts);
            this.atlasJsonRequestMap.delete(url);
            return opts;
        }
    }
}
let atlasJsonLoader=new AtlasJsonLoader();
export {atlasJsonLoader}
